import java.util.Scanner;

public class shuiXian {
    public static int shuixianShu(int data)
    {
        int count = 0;//记录位数
        int temp = data;
        while(temp != 0)
        {
            temp /= 10;
            count++;
        }
        temp = data;
        int sum = 0;//记录和值
        for(int i = 0;i < count;i++)
        {
            int b = temp % 10;
            int c = 1;
            temp /= 10;
            for(int j = count;j > 0;j--)
                c *= b;
            sum += c;
        }
        if(sum == data)
            return 1;
        else
            return 0;
    }

    public static void main(String[] args) {
        System.out.println("请输入一个数字：");
        Scanner sc = new Scanner(System.in);
        int data = sc.nextInt();
        System.out.println("0 - " + data + "之间的水仙数有：");
        for(int i = 0;i < data;i++)
        {
            if(shuixianShu(i) == 1)
                System.out.print(i + " ");
        }
    }
}
